const Base = require('../../base.js');

module.exports = class extends Base {
  async indexAction() {
    let data = this.post()
    let result = await this.model('user/index').login(data)
    if (typeof result == 'string') {
      return this.fail(-1, result || '系统异常')
    }
    let user_info = JSON.parse(JSON.stringify(result))
    let token = await this.session('user_info', user_info)
    this.json({
      status: 200, message: '登录成功',
      data: {
        user: user_info,
        token
      }
    })
  }
};
